//NO.1920
class Solution {
public:
    vector<int> buildArray(vector<int>& nums) {
        vector<int> ans(nums.size());
        for (int i = 0; i < nums.size(); i++)
        {
            ans[i] = nums[nums[i]];
        }
        return ans;
    }
};

//NO.2824
class Solution {
public:
    int countPairs(vector<int>& nums, int target) {
        sort(nums.begin(), nums.end());
        int left = 0;
        int right = nums.size() - 1;
        int ans = 0;
        while (left < right)
        {
            if (nums[left] + nums[right] < target)
            {
                ans += (right - left);
                left++;
            }
            else
                right--;
        }
        return ans;
    }
};

